<?php
	error_reporting(E_ALL^E_NOTICE);
    require_once ('../config/config.php'); 
	session_start();
	if(empty($_SESSION['member'])){
	     echo "<script>location='../index.html';</script>";
	}
	if(!empty($_SESSION['master'])){
	    if($_SESSION['member']==$_SESSION['master']){
	        echo "<script>location='./index.php';</script>";
	    }else{
	        unset($_SESSION['master']);
	        echo "<script>alert('登陆环境发生变化，请重新登录！');location='../index.html';</script>";
	    }
	}
	if($_POST['submit']){
	    $rs=mysqli_fetch_array(mysqli_query($con,"select * from master where user='".$_SESSION['member']."'"));
	    if($rs['user']==$_SESSION['member']){
			if($rs['state']!="1"){
				exit("<script>alert('该账号被限制登录后台管理系统！');location='../index.php';</script>");
			}
	        $_SESSION['master']=$_SESSION['member'];
	        mysqli_query($con,$sql="insert into masterLog values('','".$_SESSION['member']."','".getip()."','".date("Y/m/d H:i:s")."')");
	        echo "<script>location='./index.php';</script>";
	    }else{
	        echo "<script>alert('该账号暂无权限！');location='../index.html';</script>";
	    }
	}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台管理系统 - 登录</title>
    <link rel="stylesheet" type="text/css" href="css/login.css">
</head>
<body>
    <div id="wrapper" class="login-page">
        <div id="login_form" class="form">
            <form class="login-form" action="./login.php" method="post">
                <h2>欢迎您，<?php echo $_SESSION['member'];?> ,您是否要登陆后台管理系统？</h2>
                <input type="submit" name="submit" value="立即登录" id="login" />
                <a href="../index.php" id="login">返回</a>
            </form>
        </div>
    </div>
    <script src="js/jquery.min.js"></script>
</body>
</html>